#!/bin/bash
if [ "$#" -eq 0 ]; then
    FS_NAME=initrd.img
else
    # 如果有参数，则将第一个参数赋值给VERSION
    FS_NAME="$1"
    echo "打包镜像: $FS_NAME"
fi
cd "$(dirname "$0")"
SCRIPT_DIR=$(pwd)
BUILD_DIR=$SCRIPT_DIR/build
INSTALL_DIR=$BUILD_DIR/_install

cd $BUILD_DIR
sudo rm -rf $FS_NAME fs
dd if=/dev/zero of=./$FS_NAME bs=1M count=1024
mkfs.ext4 $FS_NAME
mkdir fs
sudo mount -o loop $FS_NAME ./fs
sudo cp -rf $INSTALL_DIR/* ./fs
sudo umount ./fs